﻿using System.Activities;
using System.ComponentModel;
using SLS.ExClassLib.Data;
using SLS.ExClassLib.MVVM;
namespace SLS.ExClassLib.WFActivities
{ 
    /// <summary>
    /// The display prompt.
    /// </summary>
    public sealed class LoadForeignKeyTable : CodeActivity
    {
        #region Properties

        [DefaultValue(null)]
        public InArgument<ExDataRow> VJob { get; set; }
        ExDataRow job;
        #endregion

        #region Methods

        /// <summary>
        /// The cache metadata.
        /// </summary>
        /// <param name="metadata">
        /// The metadata.
        /// </param>
        protected override void CacheMetadata(CodeActivityMetadata metadata)
        {
            metadata.RequireExtension(typeof(IDataModel));
            metadata.AddArgument(new RuntimeArgument("VJob", typeof(ExDataRow), ArgumentDirection.In, false));
        }

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override void Execute(CodeActivityContext context)
        {
            var vm = context.GetExtension<IDataModel>();
            job = this.VJob.Get(context);
            vm.LoadForeignKeyTable(job);
        }
        #endregion
    }
}